<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.jhs.kjs.model.UserModel"%>
<%@ include file="/WEB-INF/views/include/top.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
	<div class="sub">
		<div class="sub_left">
			
			<ul>
				<c:forEach var = "menuList" items="${menuList}">
					<li><a href="#" <c:if test="${menuList.menuIndex == menu.menuIndex}"> class="menu_on" </c:if> onClick="goBoardListMain(<c:out value="${menuList.menuIndex}" />)"><c:out value="${menuList.menuName}" /></a></li>				
				</c:forEach>
			</ul>
		</div>
		<div class="sub_content">
			<div class="title">
				<div class="tit"><c:out value="${menu.menuName}"/><%-- <img src="${imgUrl}/sub_tit4.jpg" border="0" /> --%></div>
				<div class="home">HOME > <font color="#4a7ed5"><c:out value="${menu.menuName}"/></font></div>
			</div>
			<div class="content">
				<table border="0" cellspacing="0" cellpadding="0" width="100%" class="notice_view">
					<tr>
						<td height="2" bgcolor="#4a7ed5" colspan="6"></td>
					</tr>
					<tr>
						<td width="94" height="34" bgcolor="#f7f7f7" class="t1">제목</td>
						<td width="3" bgcolor="#f7f7f7"><font color="#cacaca">|</font></td>
						<td class="c1" bgcolor="#f7f7f7" colspan="4"><b><c:out value="${boardView.title}" /></b></td>
					</tr>
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td width="94" height="34" class="t1">등록자</td>
						<td width="3"><font color="#cacaca">|</font></td>
						<td width="400" class="c1" colspan="4">						
							<table width=100%>
							<c:forEach var="provider" items="${provider}">
							<tr>
								<td><c:out value="${provider.providerName}"/>/<c:out value="${provider.providerAddress}"/></td>
							</tr>
							</c:forEach>
							</table>
						</td>
						
					</tr>
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td width="62" height="34" class="t1">누적금액</td>
						<td width="3"><font color="#cacaca">|</font></td>
						<td class="c1" colspan="4"><font color="#cf5050"><b><c:out value="${boardView.sumPoint}" />원</b></font></td>
					</tr>
					<c:if test="${boardView.attachment != null && boardView.attachment !=''}">
					
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td width="62" height="34" class="t1">첨부파일</td>
						<td width="3"><font color="#cacaca">|</font></td>
						<td class="c1" colspan="4"><font color="#cf5050"><a href = "/board/download?menuIndex=${menu.menuIndex}&textID=${textID}"><c:out value="${boardView.attachment}" /></a></font></td>
					</tr>
					</c:if>
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td class="c2" colspan="6">
						<c:if test="boardView.imgAttachmentPath != null && boardView.imgAttachmentPath != ''">
						<img src="${imgUrl}/../../../customerResource/<c:out value="${boardView.imgAttachmentPath}" />" style="max-width:600px"/>
						</c:if>
						<c:out value="${boardView.contents}" escapeXml="false" />
						</td>
					</tr>
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td width="94" height="34" class="t2">다음글</td>
						<td width="3"><font color="#cacaca">|</font></td>
						<td class="c3" colspan="4"><a href="#" onClick="goBoardView(1)"><c:out value="${nextBoardView.title}" />
							<input type="hidden" name="nextTextID" id="nextTextID" value="<c:out value="${nextBoardView.textID}" />"></a>
						</td>
					</tr>
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td width="94" height="34" class="t3">이전글</td>
						<td width="3"><font color="#cacaca">|</font></td>
						<td class="c3" colspan="4">
							<a href="#" onClick="goBoardView(2)"><c:out value="${prevBoardView.title}" /></a>
							<input type="hidden" name="prevTextID" id="prevTextID" value="<c:out value="${prevBoardView.textID}" />">
						</td>
					</tr>
					<tr>
						<td height="1" bgcolor="#d5d5d5" colspan="6"></td>
					</tr>
					<tr>
						<td height="10"></td>
					</tr>
					<tr>
						<td colspan="6" align="right">
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td><%-- <a href="#"><img src="${imgUrl}/sub_btn1.jpg" border="0" /></a> --%></td>
								<td width="5"></td>
								<td><%-- <a href="#"><img src="${imgUrl}/sub_btn2.jpg" border="0" /></a> --%></td>
								<td width="5"></td>
								<td><a href="#" onClick="goBoardList()"><img src="${imgUrl}/sub_btn3.jpg" border="0"/></a></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
<form  style="display:none;" id="frm" name="frm">
	<input type="text" name="menuIndex" id="menuIndex" value="${menu.menuIndex}">
	<input type="text" name="textID" id="paramTextID" value="${textID}">
	<input type="text" name="attachment" id="attachment" value="<c:out value="${boardView.attachment}" />">
	<input type="text" name="attachmentPath" id="attachmentPath" value="<c:out value="${boardView.attachmentPath}" />">
	<input type="text" name="imgAttachment" id="imgAttachment" value="<c:out value="${boardView.imgAttachment}" />">
	<input type="text" name="imgAttachmentPath" id="imgAttachmentPath" value="<c:out value="${boardView.imgAttachmentPath}" />">
	<input type="text" name="mode" id="mode">
</form> 

<script type="text/javascript">
function goBoardListMain(type) {
	// type = 1 공지사항
		// type = 2 최신판례
		// type = 3 최신법령
		// type = 4 A항목
		// type = 5 B항목
		// type = 6 C항목
		// type = 7 D항목
		// type = 8 E항목
		// type = 9 F항목
		// type = 10 G항목
		// type = 11 H항목
		$("#menuIndex").val(type);
		var url = "/board/boardListMain";	
		
		$("#frm").attr("action", url);
		$("#frm").attr("method", "post");
		$("#frm").submit();		
		
		
		return false;
  }
  
  function goBoardList() {
	var type = $("#menuIndex").val();	  
	var url = "/board/boardListMain";	
		
	$("#frm").attr("action", url);
	$("#frm").attr("method", "post");
	$("#frm").submit();
	
	return false;
  }
  function fileDownload() {
	var param = "fileName="+$("#attachmentPath").val()+"&originalFileName="+$("#attachment").val();
	location.href= "/admin/download?"+param;
  }
  
  function goBoardView(type) {
	//로그인 체크
		<% if(session.getAttribute(UserModel.USER_SESSION_INFO) == null) {%> 
			$("#frm").attr("action", "/board/userBoardView");
			$("#frm").attr("method", "post");
		  	$("#frm").submit();
		<% }%>
		if (type == 1) {
			$("#paramTextID").val($("#nextTextID").val());
		} else {
			$("#paramTextID").val($("#prevTextID").val());
		}
		var textID = $("#paramTextID").val();
		var myPoint = 0, boardPoint = 0;
		var isUseCheck = "N";
		
		var url='/board/getMyInfo.json';
		var param = "textID="+textID+"&menuIndex="+$("#menuIndex").val();
		
		AjaxPost(url, param, function(data){
			myPoint = data.userData.point; //내 금액
			boardPoint = data.boardData.usePoint; //게시글의 구매금액
			isUseCheck = data.usePointCheck; //구매체크
			<% if(!"40".equals(session.getAttribute(UserModel.USER_LEVEL))){ %>
			if(myPoint < boardPoint) {
				alert('포인트가 부족합니다.');
				return;			
			}
			
			if(isUseCheck != 'Y') {
				if(!confirm('구매 하시겠습니까?')) {
					return;
				}
			}
						
			<% } %>
			$("#frm").attr("action", "/board/boardView");
			$("#frm").attr("method", "post");
		  	$("#frm").submit();
		});	
	  	
  	return false;
	}
</script>
<%@ include file="/WEB-INF/views/include/bottom.jsp" %>